package manager;

import java.util.ArrayList;
import data.dao.*;
import data.dto.*;
import data.searchdto.*;
import data.dao.daoFactory.*;

public class LeaveDetailManager {
	private LeaveDetailDAO leaveDetailDAO;
	private LeaveDetailCommentDAO leaveDetailCommentDAO;
	private LeaveDetailTypeDAO leaveDetailTypeDAO;
	private NatureOfLeaveDAO natureofleavedao;

	private ArrayList<LeaveDetailDTO> leaveDetailList;
	private ArrayList<LeaveDetailCommentDTO> leaveDetailCommentList;
	private ArrayList<LeaveDetailTypeDTO> leaveDetailTypelist;
	private ArrayList<NatureOfLeaveDTO> natureOfLeavelist;

	public LeaveDetailManager() {
		this.leaveDetailDAO = LeaveFactory.loadInstance().getLeaveDetailDAO();
		this.leaveDetailCommentDAO = LeaveFactory.loadInstance()
				.getLeaveDetailCommentDAO();
		this.leaveDetailTypeDAO = LeaveFactory.loadInstance()
				.getLeaveDetailTypeDAO();
		this.natureofleavedao = LeaveFactory.loadInstance()
				.getNatureOfLeaveDAO();
	}

	// Leave Detail Class functions start
	public LeaveDetailDTO findLeaveDetail(
			LeaveDetailSearchDTO leavedetailsearchdto) throws LeaveDAOException {
		LeaveDetailDTO leaveDetail = new LeaveDetailDTO();
		try {
			leaveDetail = leaveDetailDAO.findLeaveDetail(leavedetailsearchdto);
		} catch (LeaveDAOException e) {
			e.printStackTrace();
		}
		return leaveDetail;
	}

	public ArrayList<LeaveDetailDTO> findAllLeaveDetail()
			throws LeaveDAOException {
		leaveDetailList = new ArrayList<LeaveDetailDTO>();
		try {
			leaveDetailList = leaveDetailDAO.findAllLeaveDetail();
		} catch (LeaveDAOException e) {
			e.printStackTrace();
		}
		return leaveDetailList;
	}

	public void insertLeaveDetail(LeaveDetailDTO LeaveDetail)
			throws LeaveDAOException {
		try {
			leaveDetailDAO.insertLeaveDetail(LeaveDetail);
		} catch (LeaveDAOException e) {
			e.printStackTrace();
		}

	}

	public void updateLeaveDetail(LeaveDetailDTO LeaveDetail)
			throws LeaveDAOException {
		try {
			leaveDetailDAO.updateLeaveDetail(LeaveDetail);
		} catch (LeaveDAOException e) {
			e.printStackTrace();
		}

	}

	public void deleteLeaveDetail(LeaveDetailDTO LeaveDetail)
			throws LeaveDAOException {
		try {
			leaveDetailDAO.deleteLeaveDetail(LeaveDetail);
		} catch (LeaveDAOException e) {
			e.printStackTrace();
		}

	}

	// Leave Detail Class functions end

	// Leave Detail Comment Class functions start

	public ArrayList<LeaveDetailCommentDTO> findAllLeaveDetailComment()
			throws LeaveDAOException {
		leaveDetailCommentList = new ArrayList<LeaveDetailCommentDTO>();
		try {
			leaveDetailCommentList = leaveDetailCommentDAO
					.findAllLeaveDetailComment();
		} catch (LeaveDAOException e) {
			e.printStackTrace();
		}
		return leaveDetailCommentList;
	}

	public void insertHero(LeaveDetailCommentDTO leaveDetailComment)
			throws LeaveDAOException {
		try {
			leaveDetailCommentDAO.insertHero(leaveDetailComment);
		} catch (LeaveDAOException e) {
			e.printStackTrace();
		}

	}

	public void updateHero(LeaveDetailCommentDTO leaveDetailComment)
			throws LeaveDAOException {
		try {
			leaveDetailCommentDAO.updateHero(leaveDetailComment);
		} catch (LeaveDAOException e) {
			e.printStackTrace();
		}

	}

	public void deleteHero(LeaveDetailCommentDTO leaveDetailComment)
			throws LeaveDAOException {
		try {
			leaveDetailCommentDAO.deleteHero(leaveDetailComment);
		} catch (LeaveDAOException e) {
			e.printStackTrace();
		}

	}

	// Leave Detail Comment Class functions end

	// Leave Detail type Class functions start

	public ArrayList<LeaveDetailTypeDTO> findLeaveDetailType(
			LeaveDetailSearchDTO leavedetailsearchdto) throws LeaveDAOException {
		leaveDetailTypelist = new ArrayList<LeaveDetailTypeDTO>();

		try {
			leaveDetailTypelist = leaveDetailTypeDAO
					.findLeaveDetailType(leavedetailsearchdto);
		} catch (LeaveDAOException e) {
			e.printStackTrace();
		}
		return leaveDetailTypelist;
	}

	public ArrayList<LeaveDetailTypeDTO> findAllLeaveDetailType()
			throws LeaveDAOException {
		leaveDetailTypelist = new ArrayList<LeaveDetailTypeDTO>();

		try {
			leaveDetailTypelist = leaveDetailTypeDAO.findAllLeaveDetailType();
		} catch (LeaveDAOException e) {
			e.printStackTrace();
		}
		return leaveDetailTypelist;
	}

	public void insertLeaveDetailType(LeaveDetailTypeDTO LeaveDetail)
			throws LeaveDAOException {
		try {
			leaveDetailTypeDAO.insertLeaveDetailType(LeaveDetail);
		} catch (LeaveDAOException e) {
			e.printStackTrace();
		}
	}

	public void updateLeaveDetailType(LeaveDetailTypeDTO LeaveDetail)
			throws LeaveDAOException {
		try {
			leaveDetailTypeDAO.updateLeaveDetailType(LeaveDetail);
		} catch (LeaveDAOException e) {
			e.printStackTrace();
		}

	}

	public void deleteLeaveDetailType(LeaveDetailTypeDTO LeaveDetail)
			throws LeaveDAOException {
		try {
			leaveDetailTypeDAO.deleteLeaveDetailType(LeaveDetail);
		} catch (LeaveDAOException e) {
			e.printStackTrace();
		}

	}

	// Leave Detail type Class functions end

	// Nature of leave Class functions start

	public ArrayList<NatureOfLeaveDTO> findNatureOfLeavebyName(
			NatureOfLeaveSearchDTO natureofleavesearchdto)
			throws LeaveDAOException {

		natureOfLeavelist = new ArrayList<NatureOfLeaveDTO>();
		try {
			natureOfLeavelist = natureofleavedao
					.findNatureOfLeavebyName(natureofleavesearchdto);
		} catch (LeaveDAOException e) {
			e.printStackTrace();
		}
		return natureOfLeavelist;
	}

	public ArrayList<NatureOfLeaveDTO> findAllNatureOfLeave()
			throws LeaveDAOException {
		natureOfLeavelist = new ArrayList<NatureOfLeaveDTO>();
		try {
			natureOfLeavelist = natureofleavedao.findAllNatureOfLeave();
		} catch (LeaveDAOException e) {
			e.printStackTrace();
		}
		return natureOfLeavelist;
	}

	public void insertLeaveDetailType(NatureOfLeaveDTO LeaveDetail)
			throws LeaveDAOException {
		// TODO Auto-generated method stub

	}

	public void updateLeaveDetailType(NatureOfLeaveDTO LeaveDetail)
			throws LeaveDAOException {
		// TODO Auto-generated method stub

	}

	public void deleteLeaveDetailType(NatureOfLeaveDTO LeaveDetail)
			throws LeaveDAOException {
		// TODO Auto-generated method stub

	}

	// Nature of leave Class functions end
}
